//
//  MyGakkiView.m
//  ShowMyGakki
//
//  Created by 金嘉健 on 2018/7/20.
//  Copyright © 2018年 金嘉健. All rights reserved.
//

#import "MyGakkiView.h"
#import <Masonry/Masonry.h>

@interface MyGakkiView()


@end

@implementation MyGakkiView

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self configUI];
    }
    
    return self;
}

#pragma private

- (void)configUI{
    
    UIImage *image = [UIImage imageNamed:@"111.jpg"];
    CALayer *imageLayer = [CALayer layer];
    imageLayer.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 400);
    imageLayer.contents = (__bridge id)image.CGImage;
    imageLayer.contentsGravity = kCAGravityCenter;
    imageLayer.contentsScale = image.scale;
    imageLayer.contentsRect = CGRectMake(0.5, 0, .3, 1.);

    [self.layer addSublayer:imageLayer];
    
    UILabel *label = [UILabel new];
    label.text = @"💖";
    [self addSubview:label];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
    }];
    
}

//- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{
//
//    CGContextSetLineWidth(ctx, 4.0f);
//    CGContextSetStrokeColorWithColor(ctx, [UIColor blueColor].CGColor);
//    CGContextStrokeEllipseInRect(ctx, layer.bounds);
//
//}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


@end
